package com.fengniu.ejb.dao.impl;

import java.util.Date;
import java.util.List;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

import org.apache.log4j.Logger;
import org.jboss.ejb3.annotation.LocalBinding;
import org.jboss.ejb3.annotation.RemoteBinding;

import com.fengniu.ejb.dao.SiteDaoLocal;
import com.fengniu.ejb.dao.SiteDaoRemote;
import com.fengniu.ejb.dao.util.DaoUtil;
import com.fengniu.ejb.dao.util.IEJBConstants;
import com.fengniu.ejb.entity.Site;
import com.fengniu.ejb.entity.Site2Category;
import com.fengniu.ejb.entity.Site2Content;
import com.fengniu.ejb.entity.Site2Site;
import com.fengniu.ejb.entity.User;

@Stateless
@LocalBinding(jndiBinding = IEJBConstants.SiteDaoLocalJndiName)
@RemoteBinding(jndiBinding = IEJBConstants.SiteDaoRemoteJndiName)
public class SiteDaoImpl implements SiteDaoLocal, SiteDaoRemote {
	static Logger logger = Logger.getLogger(SiteDaoImpl.class);

	/**
	 * 
	 */
	private static final long serialVersionUID = -4283402492463468903L;

	@PersistenceContext(unitName = "default")
	protected EntityManager em;

	public Site2Category findSite2CategoryBy(String siteId, Integer relationId, String categoryId, Integer statusId) {
		Integer[] relationIds = { relationId };
		Integer[] statusIds = { statusId };
		List<Site2Category> s2gs = this.getListSite2CategoryBy(siteId, relationIds, categoryId, null, statusIds, null,
				0, 1, null);
		if (s2gs != null && s2gs.size() > 0)
			return s2gs.get(0);
		return null;
	}

	public Site2Category findSite2CategoryBy(long siteSysId, Integer relationId, long categorySysId) {
		Integer[] relationIds = { relationId };
		List<Site2Category> s2gs = this.getListSite2CategoryBy(siteSysId, relationIds, categorySysId, null, null, 0, 1,
				null);
		if (s2gs != null && s2gs.size() > 0) {
			return s2gs.get(0);
		}
		return null;
	}

	public Site2Content findSite2ContentBy(long site2ContentSysId) {
		return em.find(Site2Content.class, site2ContentSysId);
	}

	public Site2Content findSite2ContentBy(String siteId, Integer relationId, String contentId) {
		Integer[] relationIds = { relationId };
		List<Site2Content> s2cs = this.getListSite2ContentBy(siteId, relationIds, contentId, null, null, 0, 1, null);
		if (s2cs != null && s2cs.size() > 0)
			return s2cs.get(0);
		return null;
	}

	public Site2Content findSite2ContentBy(long siteSysId, Integer relationId, long contentSysId) {
		Integer[] relationIds = { relationId };
		List<Site2Content> s2cs = this.getListSite2ContentBy(siteSysId, relationIds, contentSysId, null, null, null,
				null, 0, 1, null);
		if (s2cs != null && s2cs.size() > 0)
			return s2cs.get(0);
		return null;
	}

	public Site2Site findSite2SiteBy(String homeUrl, Integer relationId, String homeUrl2) {
		// TODO Auto-generated method stub
		return null;
	}

	public Site2Site findSite2SiteBy(long site2SiteSysId) {
		return em.find(Site2Site.class, site2SiteSysId);
	}

	public Site findSiteBySysId(long sysId) {
		Site result = em.find(Site.class, sysId);
		return result;
	}

	public Site findSiteBySiteId(String siteId) {
		List siteList = this.findByProperty("siteId", siteId, 1);
		if (siteList != null && siteList.size() > 0)
			return (Site) siteList.get(0);
		return null;
	}

	public long getCountSiteBy(Integer[] siteTypeIds, Date beforeDate) {
		Long result = new Long(0);
		Query q = this.getQuerySiteBy(siteTypeIds, beforeDate, null, false);

		result = (Long) q.getSingleResult();

		return result;
	}

	@SuppressWarnings("unchecked")
	public List<Site2Content> getListSite2ContentBy(long siteSysId, Integer[] relationIds, long contentSysId,
			Integer[] statusIds, Integer[] contentTypeIds, Integer[] site2SiteCategoryRelationIds,
			String siteCategoryId, int pgno, int pgsize, String orderBy) {
		Query q = this.getQuerySite2ContentBy(siteSysId, relationIds, contentSysId, statusIds, contentTypeIds,
				site2SiteCategoryRelationIds, siteCategoryId, null, true);
		List<Site2Content> result = DaoUtil.getResultList(q, pgno, pgsize);
		return result;
	}

	public List<Site> getListSiteBy(Integer[] siteTypeIds, Date beforeDate, int pgno, int pgsize, String orderBy) {
		Query q = this.getQuerySiteBy(siteTypeIds, beforeDate, orderBy, true);
		List result = DaoUtil.getResultList(q, pgno, pgsize);
		return result;
	}

	@TransactionAttribute(TransactionAttributeType.REQUIRED)
	public Site saveSite(Site site) {
		Site c = em.merge(site);
		return c;
	}

	public Site2Category saveSite2Category(Site2Category site2Category) {
		return em.merge(site2Category);
	}

	public Site2Content saveSite2Content(Site2Content site2Content) {
		return em.merge(site2Content);
	}

	public Site2Site saveSite2Site(Site2Site site2Site) {
		return em.merge(site2Site);
	}

	public void deleteSiteBySiteId(String siteId) {
		Site u = findSiteBySiteId(siteId);
		if (u != null) {
			em.remove(u);
		}
	}

	public Site2Category findSite2CategoryBy(String siteId, Integer relationId, String categoryId) {
		Site2Category result = null;
		Integer[] rIds = { relationId };
		List<Site2Category> c2cs = this.getListSite2CategoryBy(siteId, rIds, categoryId, null, null, null, 0, 1, null);
		if (c2cs != null && c2cs.size() > 0)
			result = c2cs.get(0);
		return result;
	}

	public long getCountSite2CategoryBy(long webSiteSysId, Integer[] relationIds, long categorySysId,
			Integer[] statusIds, Integer[] siteTypeIds) {
		Long result = new Long(0);
		Query q = this.getQuerySite2CategoryBy(webSiteSysId, relationIds, categorySysId, statusIds, siteTypeIds, null,
				false);

		result = (Long) q.getSingleResult();

		return result;
	}

	public long getCountSite2CategoryBy(String siteId, Integer[] relationIds, String categoryId, String bizCategoryId,
			Integer[] statusIds, Integer[] siteTypeIds) {
		Long result = new Long(0);
		Query q = this.getQuerySite2CategoryBy(siteId, relationIds, categoryId, bizCategoryId, statusIds, siteTypeIds,
				null, false);

		result = (Long) q.getSingleResult();

		return result;
	}

	public List<Site2Category> getListSite2CategoryBy(long webSiteSysId, Integer[] relationIds, long categorySysId,
			Integer[] statusIds, Integer[] siteTypeIds, int pgno, int pgsize, String orderBy) {
		Query q = this.getQuerySite2CategoryBy(webSiteSysId, relationIds, categorySysId, statusIds, siteTypeIds,
				orderBy, true);
		List result = DaoUtil.getResultList(q, pgno, pgsize);
		return result;
	}

	private Query getQuerySite2CategoryBy(long siteSysId, Integer[] relationIds, long categorySysId,
			Integer[] statusIds, Integer[] siteTypeIds, String orderBy, boolean isGetList) {

		String ent = isGetList ? " s2g" : "count(s2g)";

		String eql = "select " + ent + " from  Site2Category s2g";
		String whereand = "";
		if (siteSysId > 0) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.site.sysId=:siteSysId ";
		}
		if (!DaoUtil.isNull(relationIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.relationId IN (:relationIds) ";
		}
		if (categorySysId > 0) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.category.sysId=:categorySysId ";
		}
		if (!DaoUtil.isNull(statusIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.status IN (:statusIds) ";
		}
		if (!DaoUtil.isNull(siteTypeIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.site.typeId IN (:siteTypeIds) ";
		}
		if (isGetList && orderBy != null && orderBy.trim() != "") {
			eql += " ORDER BY " + orderBy;
		}

		logger.info("eql=[" + eql + "]");
		Query q = em.createQuery(eql);
		if (siteSysId > 0) {
			q.setParameter("siteSysId", siteSysId);
		}
		if (DaoUtil.isNull(relationIds) == false) {
			List rts = DaoUtil.getListFromArray(relationIds);
			q.setParameter("relationIds", rts);
		}
		if (categorySysId > 0) {
			q.setParameter("categorySysId", categorySysId);
		}
		if (DaoUtil.isNull(statusIds) == false) {
			List rts = DaoUtil.getListFromArray(statusIds);
			q.setParameter("statusIds", statusIds);
		}
		if (DaoUtil.isNull(siteTypeIds) == false) {
			List rts = DaoUtil.getListFromArray(siteTypeIds);
			q.setParameter("siteTypeIds", rts);
		}

		return q;
	}

	private Query getQuerySite2SiteBy(long siteSysId, Integer[] relationIds, long siteSysId2, Integer[] statusIds,
			String orderBy, boolean isGetList) {

		String ent = isGetList ? " s2s" : "count(s2s)";

		String eql = "select " + ent + " from  Site2Site s2s";
		String whereand = "";
		if (siteSysId > 0) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2s.site.sysId=:siteSysId ";
		}
		if (!DaoUtil.isNull(relationIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2s.relationId IN (:relationIds) ";
		}
		if (siteSysId2 > 0) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2s.site2.sysId=:siteSysId2 ";
		}
		if (!DaoUtil.isNull(statusIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2s.status IN (:statusIds) ";
		}

		logger.info("eql=[" + eql + "]");
		Query q = em.createQuery(eql);
		if (siteSysId > 0) {
			q.setParameter("siteSysId", siteSysId);
		}
		if (DaoUtil.isNull(relationIds) == false) {
			List rts = DaoUtil.getListFromArray(relationIds);
			q.setParameter("relationIds", rts);
		}
		if (siteSysId2 > 0) {
			q.setParameter("siteSysId2", siteSysId2);
		}
		if (DaoUtil.isNull(statusIds) == false) {
			List rts = DaoUtil.getListFromArray(statusIds);
			q.setParameter("statusIds", statusIds);
		}

		return q;
	}

	/**
	 * get query of site
	 * 
	 * @param siteTypeIds
	 * @param beforeDate
	 * @param orderBy
	 * @param isGetList
	 * @return
	 */
	private Query getQuerySiteBy(Integer[] siteTypeIds, Date beforeDate, String orderBy, boolean isGetList) {

		String ent = isGetList ? " s" : "count(s)";

		String eql = "select " + ent + " from  Site s";
		String whereand = "";

		if (!DaoUtil.isNull(siteTypeIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s.typeId IN (:siteTypeIds) ";
		}
		if (isGetList && orderBy != null && orderBy.trim() != "") {
			eql += " ORDER BY " + orderBy;
		}
		logger.debug("eql=[" + eql + "]");

		Query q = em.createQuery(eql);

		if (DaoUtil.isNull(siteTypeIds) == false) {
			List rts = DaoUtil.getListFromArray(siteTypeIds);
			q.setParameter("siteTypeIds", rts);
		}

		return q;
	}

	@SuppressWarnings("unchecked")
	public List<Site2Category> getListSite2CategoryBy(String siteId, Integer[] relationIds, String categoryId,
			String bizCategoryId, Integer[] statusIds, Integer[] siteTypeIds, int pgno, int pgsize, String orderBy) {
		Query q = this.getQuerySite2CategoryBy(siteId, relationIds, categoryId, bizCategoryId, statusIds, siteTypeIds,
				null, true);
		List<Site2Category> result = DaoUtil.getResultList(q, pgno, pgsize);
		return result;
	}

	private Query getQuerySite2CategoryBy(String siteId, Integer[] relationIds, String categoryId,
			String bizCategoryId, Integer[] statusIds, Integer[] siteTypeIds, String orderBy, boolean isGetList) {

		String ent = isGetList ? "s2g" : "count(s2g)";

		String eql = "select " + ent + " from  Site2Category s2g";

		String whereand = "";
		if (bizCategoryId != null) {
			eql += ", Site2Category s2gbiz WHERE s2g.site = s2gbiz.site AND s2gbiz.category.categoryId=:bizCategoryId";
			whereand = DaoUtil.getWhereOrAndStr(whereand);
		}

		if (siteId != null) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.site.siteId=:siteId ";
		}
		if (!DaoUtil.isNull(relationIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.relationId IN (:relationIds) ";
		}
		if (categoryId != null) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.category.categoryId=:id ";
		}
		if (!DaoUtil.isNull(statusIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.status IN (:statusIds) ";
		}
		if (!DaoUtil.isNull(siteTypeIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2g.site.typeId IN (:siteTypeIds) ";
		}
		if (isGetList && orderBy != null && orderBy.trim() != "") {
			eql += " ORDER BY " + orderBy;
		}

		logger.debug("eql=[" + eql + "]");
		Query q = em.createQuery(eql);
		if (bizCategoryId != null) {
			q.setParameter("bizCategoryId", bizCategoryId);
		}
		if (siteId != null) {
			q.setParameter("siteId", siteId);
		}
		if (DaoUtil.isNull(relationIds) == false) {
			List rts = DaoUtil.getListFromArray(relationIds);
			q.setParameter("relationIds", rts);
		}
		if (categoryId != null) {
			q.setParameter("id", categoryId);
		}
		if (DaoUtil.isNull(statusIds) == false) {
			q.setParameter("statusIds", statusIds);
		}
		if (DaoUtil.isNull(siteTypeIds) == false) {
			List rts = DaoUtil.getListFromArray(siteTypeIds);
			q.setParameter("siteTypeIds", rts);
		}

		return q;
	}

	public void deleteSite2Category(long site2CategorySysId) {
		Site2Category s2g = em.find(Site2Category.class, site2CategorySysId);
		if (s2g != null)
			em.remove(s2g);
	}

	private Query getQuerySite2ContentBy(String siteId, Integer[] relationIds, String contentId, Integer[] statusIds,
			Integer[] contentTypeIds, String orderBy, boolean isGetList) {

		String ent = isGetList ? "s2c" : "count(s2c)";

		String eql = "select " + ent + " from  Site2Content s2c  ";
		String whereand = "";
		if (siteId != null) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.site.siteId=:siteId ";
		}
		if (!DaoUtil.isNull(relationIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.relationId IN (:relationIds) ";
		}
		if (contentId != null) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.content.contentId=:contentId ";
		}
		if (!DaoUtil.isNull(statusIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.status IN (:statusIds) ";
		}

		if (!DaoUtil.isNull(contentTypeIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.content.typeId IN (:contentTypeIds) ";
		}
		logger.debug("eql=[" + eql + "]");
		Query q = em.createQuery(eql);
		if (siteId != null) {
			q.setParameter("siteId", siteId);
		}
		if (!DaoUtil.isNull(relationIds)) {
			List rts = DaoUtil.getListFromArray(relationIds);
			q.setParameter("relationIds", rts);
		}
		if (contentId != null) {
			q.setParameter("contentId", contentId);
		}
		if (!DaoUtil.isNull(statusIds)) {
			List rts = DaoUtil.getListFromArray(statusIds);
			q.setParameter("statusIds", rts);
		}
		if (!DaoUtil.isNull(contentTypeIds)) {
			List rts = DaoUtil.getListFromArray(contentTypeIds);
			q.setParameter("contentTypeIds", rts);
		}

		return q;
	}

	private Query getQuerySite2ContentBy(long siteSysId, Integer[] relationIds, long contentSysId, Integer[] statusIds,
			Integer[] contentTypeIds, Integer[] site2SiteCategoryRelationIds, String siteCategoryId, String orderBy,
			boolean isGetList) {

		String ent = isGetList ? "s2c" : "count(s2c)";

		String eql = "select " + ent + " from  Site2Content s2c  ";

		String whereand = "";
		if (siteCategoryId != null) {
			eql += ", Site2Category s2g WHERE s2g.category.categoryId=:siteCategoryId AND s2g.site.sysId = s2c.site.sysId ";
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			if (site2SiteCategoryRelationIds != null) {
				whereand = DaoUtil.getWhereOrAndStr(whereand);
				eql += whereand + " s2g.relationId IN (:site2SiteCategoryRelationIds) ";
			}
		}

		if (siteSysId > 0) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.site.sysId=:siteSysId ";
		}
		if (!DaoUtil.isNull(relationIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.relationId IN (:relationIds) ";
		}
		if (contentSysId > 0) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.content.sysId=:contentSysId ";
		}
		if (!DaoUtil.isNull(statusIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.status IN (:statusIds) ";
		}

		if (!DaoUtil.isNull(contentTypeIds)) {
			whereand = DaoUtil.getWhereOrAndStr(whereand);
			eql += whereand + "  s2c.content.typeId IN (:contentTypeIds) ";
		}

		if (isGetList) {
			eql += " order by s2c.lastUpdatedDate desc";
		}

		logger.debug("eql=[" + eql + "]");
		Query q = em.createQuery(eql);
		if (siteCategoryId != null) {
			q.setParameter("siteCategoryId", siteCategoryId);
			if (site2SiteCategoryRelationIds != null) {
				List rts = DaoUtil.getListFromArray(site2SiteCategoryRelationIds);
				q.setParameter("site2SiteCategoryRelationIds", rts);
			}
		}

		if (siteSysId > 0) {
			q.setParameter("siteSysId", siteSysId);
		}
		if (!DaoUtil.isNull(relationIds)) {
			List rts = DaoUtil.getListFromArray(relationIds);
			q.setParameter("relationIds", rts);
		}
		if (contentSysId > 0) {
			q.setParameter("contentSysId", contentSysId);
		}
		if (!DaoUtil.isNull(statusIds)) {
			List rts = DaoUtil.getListFromArray(statusIds);
			q.setParameter("statusIds", rts);
		}
		if (!DaoUtil.isNull(contentTypeIds)) {
			List rts = DaoUtil.getListFromArray(contentTypeIds);
			q.setParameter("contentTypeIds", rts);
		}

		return q;
	}

	@SuppressWarnings("unchecked")
	private List<User> findByProperty(String propertyName, Object value, int size) {
		String queryString = "select model from Site model where model." + propertyName + "= :propertyValue";
		return em.createQuery(queryString).setParameter("propertyValue", value).setFirstResult(0).setMaxResults(size)
				.getResultList();
	}

	public void deleteSite2Content(long site2ContentSysId) {
		Site2Content s2c = em.find(Site2Content.class, site2ContentSysId);
		if (s2c != null)
			em.remove(s2c);
	}

	public long getCountSite2ContentBy(String siteId, Integer[] relationIds, String contentId, Integer[] statusIds,
			Integer[] contentTypeIds) {
		Long result = new Long(0);
		Query q = this.getQuerySite2ContentBy(siteId, relationIds, contentId, statusIds, contentTypeIds, null, false);

		result = (Long) q.getSingleResult();

		return result;
	}

	@SuppressWarnings("unchecked")
	public List<Site2Content> getListSite2ContentBy(String siteId, Integer[] relationIds, String contentId,
			Integer[] statusIds, Integer[] siteTypeIds, int pgno, int pgsize, String orderBy) {
		Query q = this.getQuerySite2ContentBy(siteId, relationIds, contentId, statusIds, siteTypeIds, orderBy, true);
		List<Site2Content> result = DaoUtil.getResultList(q, pgno, pgsize);
		return result;
	}

	public long getCountSite2ContentBy(long siteSysId, Integer[] relationIds, long contentSysId, Integer[] statusIds,
			Integer[] contentTypeIds, Integer[] site2SiteCategoryRelationIds, String siteCategoryId) {
		Long result = new Long(0);
		Query q = this.getQuerySite2ContentBy(siteSysId, relationIds, contentSysId, statusIds, contentTypeIds,
				site2SiteCategoryRelationIds, siteCategoryId, null, false);

		result = (Long) q.getSingleResult();

		return result;
	}

	public Site2Category findSiteLeafCategoryBy(long siteSysId, Integer relationId) {
		if (siteSysId > -1 && relationId != null) {
			String eql = "SELECT s2g FROM  Site2Category  s2g where  s2g.site.sysId=:siteSysId AND s2g.relationId=:relationId order by s2g.category.sysId DESC";
			Query q = em.createQuery(eql);
			q.setParameter("siteSysId", siteSysId).setParameter("relationId", relationId);
			List<Site2Category> result = DaoUtil.getResultList(q, 0, 1);
			if (result != null && result.size() > 0) {
				return result.get(0);
			}
		}
		return null;
	}

	public void updateSite2ContentStatus(long siteSysId, Integer[] relationIds, long contentSysId, Integer statusId) {
		String eql = "UPDATE Site2Content s2c set s2c.status=:statusId";
		if (statusId != null) {
			String whereand = "";
			if (siteSysId > -1) {
				whereand = DaoUtil.getWhereOrAndStr(whereand);
				eql += whereand + " s2c.site.sysId=:siteSysId";
			}
			if (!DaoUtil.isNull(relationIds)) {
				whereand = DaoUtil.getWhereOrAndStr(whereand);
				eql += whereand + "  s2c.relationId IN (:relationIds) ";
			}
			if (contentSysId > -1) {
				whereand = DaoUtil.getWhereOrAndStr(whereand);
				eql += whereand + " s2c.content.sysId=:contentSysId";
			}

			Query q = em.createQuery(eql);
			if (siteSysId > -1) {
				q.setParameter("siteSysId", siteSysId);
			}
			if (!DaoUtil.isNull(relationIds)) {
				List rts = DaoUtil.getListFromArray(relationIds);
				q.setParameter("relationIds", rts);
			}
			if (contentSysId > -1) {
				q.setParameter("contentSysId", contentSysId);
			}
			q.executeUpdate();
		}

	}

	public long getCountSite2SiteBy(long siteSysId, Integer[] relationIds, long site2SysId, Integer[] statusIds) {
		Long result = new Long(0);
		Query q = this.getQuerySite2SiteBy(siteSysId, relationIds, site2SysId, statusIds, null, false);

		result = (Long) q.getSingleResult();

		return result;
	}

	public List<Site2Site> getListSite2SiteBy(long siteSysId, Integer[] relationIds, long site2SysId,
			Integer[] statusIds, int pgno, int pgsize, String orderBy) {
		Query q = this.getQuerySite2SiteBy(siteSysId, relationIds, site2SysId, statusIds, null, true);
		List<Site2Site> result = DaoUtil.getResultList(q, pgno, pgsize);
		return result;
	}
}
